from time import sleep
from frp_page_object import new_retail_order_page
from service.base_chains_service import BaseChainsService


class TocRetailOrderService(BaseChainsService):
    def __init__(self):
        self.new_retail_page = new_retail_order_page.NewRetailOrderPage()
        super().__init__()

    def input_form_header(self, store_name, marketer_name, number, customer_name, date, address, yon):
        self.menu_frp.click_retail_order()
        self.new_retail_page.input_all_new_order(store_name, marketer_name, number, customer_name, date, address, yon)

    # def new_samples_order(self):
    def new_product(self, liaohao):
        self.new_retail_page.new_product(liaohao)

    def new_product_stocks(self, liaohao):
        self.new_retail_page.new_product_stocks(liaohao)

    def new_product_self_build(self, liaohao):
        self.new_retail_page.new_product_self_build(liaohao)

    def new_product_suite(self, liaohao, suite_names):
        self.new_retail_page.new_product_suite(liaohao, suite_names)

    def check_pre_order(self):
        self.order_number = self.new_retail_page.submit()  # 提交
        return super().check_pre_order()

    def audit(self):
        self.menu_ofc.switch_to_window_by_title('顾家家居零售分销')
        self.new_retail_page.click_audit()  # 审核
        sleep(1)
        self.menu_ofc.switch_to_window_by_title('供应链运营中台')
